<?php 
header ("content-type: text/xml");

?>	
<channel>
	<?php 
		$items	=	$data->data;
//		index.php?app=feed&task=cat&start=$1&feedId=$2
		$nextpage	=	'';
		$start	=	Request::getVar('start',0) + count($items);
		if ($data->numberView<=count($items))
			$nextpage	=	APPRouter::build(APPURI::root().'index.php?app=feed&task=cat&start='.$start.'&feedId='.$data->feedId);
		
		?>
		<items number="<?php echo  count($items); ?>" nextpage="<?php echo $nextpage; ?>">
			<section><?php echo $data->secName; ?></section>
			<category><?php echo $data->catName; ?></category>
			<title><?php echo stdContent($data->title); ?></title>
			<?php 
				for ($j=0; $j<count($items); $j++)
				{
					$item	=	$items[$j];
					$alias	=	$href->take_file_name($item->title);
//					var_dump($item);
					$link	=	APPRouter::build(APPURI::root().'index.php?app=feed&task=content&id='.$item->id.'-'.$alias);
					$intro	=	stdContent($item->introtext);
					$thumb	=	'';
					if ($item->urlThumb)
						$thumb	=	$href->process_url($item->urlThumb, APPURI::root());
					
				?>
					<item href="<?php echo $link ?>">
						<title><?php echo stdContent(strip_tags($item->title)); ?></title>
						<thumb src="<?php echo $thumb; ?>" />
						<intro><?php echo $intro; ?></intro>
						<date><?php echo $item->date_original; ?></date>
					</item>
				<?php 
			}				
			?>				
		</items>
</channel>
<?php 
function stdContent($str_in)
{
	$href	=	new href();
	$str_in	=	preg_replace('/<img[^\>]+src=("|\'|\s*)([^>"\']+)("|\'|\s*)[^\>]+>/ism','<img src="$2" />',$str_in);
	$str_in	=	preg_replace('/<br>/ism',"",$str_in);
	$str_in	=	preg_replace('/<br\s*\/>/ism',"",$str_in);
	$str_in	=	$href->process_src($str_in,APPURI::root());
	$str_in	=	str_replace('&nbsp;',' ', $str_in);	
	$str_in	=	str_replace('&','&amp;', $str_in);
	return $str_in;
}
?>